﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using Common;
using CNCSoft.ErpApps.TMS.myclass;

namespace CNCSoft.ErpApps.TMS.Counsellor
{
    public partial class frmEnquiryDetail : Form
    {
        private SqlConnection conn = new SqlConnection(GlobalVariable.WSInfo.ConnectionString);
        DataSet ds = new DataSet();
        CommonClass mine = new CommonClass();

        private string _enquirynumber;

        public string Enquirynumber
        {
            get { return _enquirynumber; }
            set { _enquirynumber = value; }
        }


        public frmEnquiryDetail()
        {
            InitializeComponent();
        }

        public frmEnquiryDetail(string enquirynumber)
        {
            InitializeComponent();
            this.Enquirynumber = enquirynumber;
        }

        private void frmEnquiryDetail_Load(object sender, EventArgs e)
        {
            try
            {
                LoadData(Enquirynumber);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        #region coding
        private void LoadData(string enquirynumber)
        {
            string sql =
                @"SELECT
                inv.InvoiceNumber AS N'Mã số học sinh', enq.EnquiryNumber AS N'Mã số tư vấn', 
                enq.Holot AS N'Họ lót', enq.Ten AS N'Tên', dmkh.TenKhoaHoc AS N'Tên lớp', dmkh.TrangThai AS N'Trạng thái',
                inv.InvoiceDate AS N'Ngày đóng tiền', inv.Amount AS N'Số tiền đã đóng'
                FROM
                Invoice inv INNER JOIN DM_KHOAHOC dmkh ON dmkh.MaKhoaHoc = inv.MaLop
                INNER JOIN Enquiry enq ON enq.EnquiryNumber = inv.EnquiryNumber
                WHERE enq.EnquiryNumber = '" + enquirynumber + "'";
            mine.ExecDataAdapter(sql, conn, ds, "TableData", gridControlData);            
        }
        #endregion
    }
}
